package cn.sunxyz.modules.memory;

/**
 * Created by yangrd on 2017/5/11.
 */
public class DefaultNodeManager<V> extends NodeMangerAdapter<V> implements NodeManger<V> {

    private DefaultNodeManager() {
    }

    public static <V> DefaultNodeManager<V> getInstance() {
        return SingletonHolder.INSTANCE;
    }

    @Override
    public void bind(V value, V... friends) {
        this.linkNode(value, friends);
    }

    @Override
    public void linkNode(V value, V... friends) {
        super.linkNode(value, friends);
        super.addRecord(value, friends);
    }

    @Override
    public void addRecord(V value, V[] friends) {
        this.linkNode(value, friends);
    }

    private static class SingletonHolder {
        private static final DefaultNodeManager INSTANCE = new DefaultNodeManager();
    }
}
